package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhCheckMissionDAO;
import com.cssy.yd.logic.entity.LogicWhCheckMissionDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-29
 */
public class LogicWhCheckMissionDAOImpl extends SqlMapClientDaoSupport implements LogicWhCheckMissionDAO {

    /**
     * 插入数据
     * @param logicWhCheckMissionDO
     * @return 插入数据的主键
     */
    public String insertLogicWhCheckMissionDO(LogicWhCheckMissionDO logicWhCheckMissionDO) throws DataAccessException {
    	logicWhCheckMissionDO.setVersion(1);
        Object id = getSqlMapClientTemplate().insert("LogicWhCheckMission.insert", logicWhCheckMissionDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhCheckMissionDO
     * @return 查出的记录数
     */
    public Integer countLogicWhCheckMissionDOByExample(LogicWhCheckMissionDO logicWhCheckMissionDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckMission.countByDOExample", logicWhCheckMissionDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhCheckMissionDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhCheckMissionDO(LogicWhCheckMissionDO logicWhCheckMissionDO) throws DataAccessException {
    	logicWhCheckMissionDO.setVersionbt(logicWhCheckMissionDO.getVersion());
    	logicWhCheckMissionDO.setVersion(logicWhCheckMissionDO.getVersion()+1);
    	int result = getSqlMapClientTemplate().update("LogicWhCheckMission.update", logicWhCheckMissionDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhCheckMissionDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhCheckMissionDO> findListByExample(LogicWhCheckMissionDO logicWhCheckMissionDO) throws DataAccessException {
        List<LogicWhCheckMissionDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckMission.findListByDO", logicWhCheckMissionDO);
        return list;
    }

    /**
     * 根据主键获取logicWhCheckMissionDO
     * @param id
     * @return logicWhCheckMissionDO
     */
    public LogicWhCheckMissionDO findLogicWhCheckMissionDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhCheckMissionDO logicWhCheckMissionDO = (LogicWhCheckMissionDO) getSqlMapClientTemplate().queryForObject("LogicWhCheckMission.findByPrimaryKey", id);
        return logicWhCheckMissionDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhCheckMissionDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhCheckMission.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhCheckMissionDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhCheckMissionDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckMission_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckMission_ex.count", scs);
  	      return count;
  	}
}